package _1到100;

import java.util.Arrays;

/**
 * @Author: WangYongGan
 * @Date: 2021/11/20 23:38
 * @Description:
 */
public class _48旋转图像 {
    public static void rotate(int[][] matrix) {
        matT(matrix);
        for(int i=0;i<matrix.length/2;i++){
            int swap=matrix.length-i-1;
            for(int j=0;j<matrix.length;j++){
                int temp=matrix[j][i];
                matrix[j][i]=matrix[j][swap];
                matrix[j][swap]=temp;
            }
        }
        for (int[] ints : matrix) {
            System.out.println(Arrays.toString(ints));
        }
    }
    public static void matT(int [][]mat){
        for(int i=0;i<mat.length;i++){
            for(int j=0;j<i;j++){
                int temp=mat[i][j];
                mat[i][j]=mat[j][i];
                mat[j][i]=temp;
            }
        }
    }
    public static void main(String[] args) {
        int[][] matrix=new int[][]{{1,2,3},{4,5,6},{7,8,9}};
        rotate(matrix);
    }
}
